/**
 * zmn渠道服务工程师-列表
 * 文件命名格式：zmn.模块名称.表名称.功能.js
 * @author xiangjunming
 * @since 2019/10/16 18:07
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;
    var laydate = layui.laydate;

    table.init('zmn-table', {
        toolbar: "#zmn-table-tool",
        page: true,
        limit: json.pageSize,
        height: 'full-140'
    });
    laypage.render(zmnPage.laypageOptions(json));

    //【表格左上侧工具栏监听】
    table.on("toolbar(zmn-table)", function (obj) {
        if(obj.event == "add") {
            var ids = zmnPage.layTabldIds(obj, "channelId");
            if(ids.length === 0){ return layer.alert("请选择至少一条数据！"); }

            layer.confirm('确认添加渠道配置吗？', function() {
                zmnPage.ajaxSimple(json.commitURL, { ids: ids.join(","), id: json.id}, 1000);
            });
            return;
        }
    });

    //【表格右侧工具栏监听】
    table.on('tool(zmn-table)', function (obj) {
        var channelId = obj.data.channelId;
        if(obj.event == "add") {
            layer.confirm('确认添加渠道配置吗？', function() {
                zmnPage.ajaxSimple(json.commitURL, { ids: channelId, id: json.id}, 1000);
            });
            return;
        }
    });

    //对外暴露的接口
    exports('channel_select_list', {});
});